package top.hekun.study.core;


import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.util.ASMifier;
import org.objectweb.asm.util.Printer;
import org.objectweb.asm.util.Textifier;
import org.objectweb.asm.util.TraceClassVisitor;
import top.hekun.study.core.util.ClassFileUtil;
import top.hekun.study.core.visitor.method.frame.MethodStackMapFrameVisitor;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;

import static org.objectweb.asm.Opcodes.ASM9;

/**
 * 打印初始frame
 *
 * @author: Sakura
 * @date: 2023/5/2
 */
public class HelloWordFrameCore {

    public static void main(String[] args) throws IOException {
        // 设置参数 或者直接给 ClassReader 传类的全名称
        byte[] classBytes = ClassFileUtil.getClassFileByteToClassName("HelloWord");


        // 类读取器 并且解析
        ClassReader classReader = new ClassReader(classBytes);

        ClassVisitor classVisitor = new MethodStackMapFrameVisitor(ASM9, null);

        classReader.accept(classVisitor,ClassReader.EXPAND_FRAMES);
    }
}
